<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	template="/resources/layout/templateInterno.xhtml"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:t="http://myfaces.apache.org/tomahawk"
    xmlns:rich="http://richfaces.org/rich">
    
    
	<ui:define name="body">
		<div class="form">
		<h:form id="formCadastroFuncao">
		<h:panelGroup id="pgMensagens">
			  <div align="center">
					<h:messages  errorClass="form-msg-error" infoClass="form-msg-success" />
			</div>
		</h:panelGroup>
		<div  class="field-clear"></div>
		  <t:fieldset id="idfsDadosPessoais"  legend="Dados">
		  
				<div class="grid-5-12">
					<h:outputLabel  id="lbNome" class="form-lbl"  value="Nome:"/>
					<h:inputText maxlength="100"  id="inptNome" styleClass="form-txt" required="true" requiredMessage="Favor informar o Nome." value="#{funcaoCadastroBean.funcao.noFuncao}" />
				</div>
				<div class="grid-2-12">
					<h:outputLabel  id="lbStatus" class="form-lbl"  value="Status:"/>
					<h:selectOneRadio id="cbStatus" required="true" requiredMessage="Favor informar o Status." value="#{funcaoCadastroBean.funcao.statusFuncao}">
						  <f:selectItem itemLabel="Ativo" itemValue="S" />
						  <f:selectItem itemLabel="Inativo" itemValue="F" />
					<a4j:support  event="onchange" ></a4j:support>  
					</h:selectOneRadio>	
				</div>
				<div class="field-clear"></div>
				<div class="grid-8-12">
					<h:outputLabel id="lbDescricao" class="form-lbl"  value="Descrição:"/>
					<h:inputTextarea rows="50" cols="150" id="inptDescricao"  styleClass="form-txt" value="#{funcaoCadastroBean.funcao.dsFuncao}" />
				</div> 
		 </t:fieldset>
		 <div  class="field-clear"> </div>
			 <div style="margin-left: 300px" class="grid-3-12">
					<a4j:commandButton style="width:100px" styleClass="form-button" id="cbSalvar" value="Salvar" reRender="idfsDadosPessoais,pgMensagens,funcaoTable" action="#{funcaoCadastroBean.salvar}" >	</a4j:commandButton>
			</div >
		<div class="field-clear"></div>
		
		 <t:fieldset id="idfsDadosIgreaj" style="width: 600px; float: left" legend="Filtros">
		 	 <div class="grid-6-12">
					<h:outputLabel class="form-lbl"  value="Nome:"/>				
					<h:inputText styleClass="form-txt"  value="#{funcaoCadastroBean.funcaoPesquisa.noFuncao}" id="nomePesquisa" />
				 </div>
			<div class="field-clear"></div>
			</t:fieldset>
		 <div class="grid-2-12">
					<a4j:commandButton id="cbPesquisar" process="idfsDadosPessoais" ajaxSingle="true"  style="margin-top:37px" styleClass="form-button" action="#{funcaoCadastroBean.pesquisarFuncao}" reRender="funcaoTable" value="Pesquisar" >
					</a4j:commandButton>
				</div>
		 <div class="field-clear"></div>
		 <div style="padding: 0px" >
			 	<rich:dataTable  onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
                    			onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'" 
                    			width="750" border="0" align="center" id="funcaoTable"  var="funcao" value="#{funcaoCadastroBean.listaFuncao}" >
				  <f:facet  name="header">
                    <rich:columnGroup >
                            <rich:column style="text-align: center;"  styleClass="ui-state-default" >
                                <strong><h:outputText value="Nome" /></strong>
                            </rich:column>
                             <rich:column style="text-align: center;"  styleClass="ui-state-default" >
                                <strong><h:outputText value="Descrição" /></strong>
                            </rich:column>
                             <rich:column style="text-align: center;"  styleClass="ui-state-default" >
                                <strong><h:outputText value="Status" /></strong>
                            </rich:column>
                             <rich:column style="text-align: center;"  styleClass="ui-state-default" >
                                <strong><h:outputText value="Operações" /></strong>
                            </rich:column>
                    	</rich:columnGroup>
                  </f:facet>
 				<rich:columnGroup >	
 					<rich:column  style="text-align: center;" >
						<h:outputText value="#{funcao.noFuncao}" />
					</rich:column>		
					 <rich:column style="text-align: center;" >
						<h:outputText value="#{funcao.dsFuncao}" />
					</rich:column>
					<rich:column  style="text-align: center;">
						<h:outputText value="#{funcao.statusFuncao}" />
					</rich:column>
					<rich:column style="text-align: center;" >
						<a4j:commandLink id="removerFuncao" ajaxSingle="true" action="#{funcaoCadastroBean.excluir}" reRender="pgMensagens,funcaoTable"  >
							 <h:graphicImage value="/resources/imagens/ico_excluir.gif" id="gIExcluirFuncao" styleClass="hidelink"/>
							 <f:setPropertyActionListener target="#{funcaoCadastroBean.coFuncao}" value="#{funcao.coSeqFuncao}"/>  
						</a4j:commandLink>
						<a4j:commandLink id="editarFuncao" ajaxSingle="true" value=" " reRender="idfsDadosPessoais"  >
							<h:graphicImage value="/resources/imagens/ico_editar.gif" id="gIEdidarFuncao" styleClass="hidelink"/>
							 <f:setPropertyActionListener target="#{funcaoCadastroBean.funcao}" value="#{funcao}"/>  
						</a4j:commandLink>
					</rich:column>
				</rich:columnGroup>
			</rich:dataTable>
		</div>
		</h:form>
		</div>
		<t:saveState id="funcaoPesquisa" value="#{funcaoCadastroBean.funcaoPesquisa}"/>
		<t:saveState id="funcaoCadastro" value="#{funcaoCadastroBean.funcao}"/>  
	</ui:define>
</ui:composition>

